<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <div ref="node">
            <div v-for="item in list">
                {{item}}
            </div>
            <button @click="add">click</button>
        </div>
    </div>
    <script>
        let app = new Vue({
            el:'#app',
            data(){
                return{
                    list:['超人','海王','绿灯侠']
                }
            },
            mounted(){
                console.log(this.$refs.node.clientHeight);
            },
            methods:{
                add(){
                    this.list.push('蝙蝠侠')
                    // Vue特点：节点渲染是异步的
                    // 获取的高度是渲染dom之前的
                    // 解决方式（如何获取数据更新后的dom节点）
                    // nextTick()
                    this.$nextTick(()=>{
                        console.log(this.$refs.node.clientHeight);
                    })
                
                }
            }
        })
    </script>
</body>
</html>